package com.park.service.impl.resource;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.park.client.model.resource.ResourceFileModel;
import com.park.client.service.resource.ResouceFileService;
import com.park.common.exception.UserDefinedException;
import com.park.common.id.IdFactoryUtils;
import com.park.dao.resource.ResourceFileMapper;
import com.park.service.impl.base.BaseServiceImpl;

@Service("resourceFileService")
public class ResourceFileServiceImpl extends BaseServiceImpl<ResourceFileModel> implements ResouceFileService {
	
	@Autowired
	private  ResourceFileMapper  fileMapper;

	@Override
	public boolean deleteByPrimaryKey(Long id) {
		return fileMapper.deleteByPrimaryKey(id)==1;
	}
	@Override
	public boolean insertSelective(ResourceFileModel record) {
		return fileMapper.insertSelective(record)==1;
	}
	@Override
	public ResourceFileModel selectByPrimaryKey(Long id) {
		return fileMapper.selectByPrimaryKey(id);
	}
	@Override
	public boolean updateByPrimaryKeySelective(ResourceFileModel record) {
		return fileMapper.updateByPrimaryKeySelective(record)==1;
	}
	@Override
	public boolean updateByPrimaryKey(ResourceFileModel record) {
		return fileMapper.updateByPrimaryKey(record)==1;
	}
	@Override
	public boolean insert(ResourceFileModel record) {
		return fileMapper.insert(record)==1;
	}
	@Override
	public List<ResourceFileModel> selectByUserId(Long userId) {
		return fileMapper.selectByUserId(userId);
	}
	@Override
	public List<ResourceFileModel> selectByTitle(ResourceFileModel fileModel) {
		return fileMapper.selectByTitle(fileModel);
	}
	@Override
	public List<ResourceFileModel> selectAll() {
		return fileMapper.selectAll();
	}
	@Override
	public List<ResourceFileModel> selectRankingList() {
		return fileMapper.selectRankingList();
	}
	@Override
	public List<ResourceFileModel> selectHostCommentList() {
		return fileMapper.selectHostCommentList();
	}
	@Override
	public List<ResourceFileModel> selectPagination(ResourceFileModel t) {
		return fileMapper.selectPagination(t);
	}
	@Override
	public Integer selectTotal(ResourceFileModel t) {
		return fileMapper.selectTotal(t);
	}
	
	@Override
	public void saveOrUpdate(ResourceFileModel record) {
		if(record == null){
			throw new UserDefinedException("100", "保存对象为空");
		}
		if(record.getId() != null){
			this.updateByPrimaryKey(record);
		}else{
			record.setId(IdFactoryUtils.getId());
			this.insert(record);
		}
	}
}
